home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
malloc
/
malloc.c
Wrap
Text File
|
1988-11-30
|
36KB
|
1,113 lines
From mnetor!seismo!ll-xn!mit-amt!mit-eddie!mirror!sources-request Fri Jul 18 22:24:02 EDT 1986
Article 444 of mod.sources:
Relay-Version: version B 2.10.2 9/18/84; site lsuc.UUCP
Path: lsuc!mnetor!seismo!ll-xn!mit-amt!mit-eddie!mirror!sources-request
>From: sources-request@mirror.UUCP
Newsgroups: mod.sources
Subject: v06i054: A "smarter" malloc (malloc)
Message-ID: <141@mirror.UUCP>
Date: 15 Jul 86 11:31:22 GMT
Date-Received: 16 Jul 86 07:29:40 GMT
Sender: rs@mirror.UUCP
Lines: 1028
Approved: rs@mirror.UUCP
Submitted by: cca!astrovax!wls (William L. Sebok)
Mod.sources: Volume 6, Issue 54
Archive-name: malloc
--------Cut Here----------
# This is a shell archive. Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by astrovax!wls on Thu Jul 3 13:20:20 EDT 1986
# Contents: README malloc.3 forget.3 malloc.h malloc.c free.c realloc.c
# forget.c tstmalloc.c asm.sed malloc.adb
echo x - README
sed 's/^@//' > "README" <<'@//E*O*F README//'
This is the malloc()/free()/realloc()/forget() package used at astrovax.
It does not have the property of the 4.2 BSD malloc of allocating huge amounts
of excess memory. Image processing is done here and large malloc requests
are not rare. It is quite undesirable when one asks for 4.1 megabytes of memory
to have it try to return 8 megabytes and to fail because the process goes over
quota or there is not enough swap space.
Also this malloc does not have the property of the 4.1 BSD malloc that a search
for free memory traverses a linked list that covers all previous allocations,
causing thrashing by touching them and thus paging them back into memory.
Hopefully this malloc covers the best of both worlds. There is a fair attempt
at storage compaction, merging freed areas with adjacent free areas and
optionally returning freed areas adjacent to the break back to the system,
thereby shrinking the size of the process.
It is also allowable and compatible with this package to obtain memory by the
use of the sbrk() system call. This memory can be reclaimed and returned to
the malloc arena by the use of the provided forget() function. This function
is intended to provide the functionality of the Forth FORGET primitive in
an environment that also includes malloc and free.
The main disadvantage of this package is a larger storage overhead of 24 bytes
per memory area, due to the fact that each area is linked into two
bi-directional chains.
Non-vax users should edit the commented system-dependent parts of Makefile and
malloc.h for the requirements of one's own computer.
Bill Sebok Princeton University, Astrophysics
{allegra,akgua,cbosgd,decvax,ihnp4,noao,philabs,princeton,vax135}!astrovax!wls
@//E*O*F README//
chmod u=rw,g=r,o=r README
echo x - malloc.3
sed 's/^@//' > "malloc.3" <<'@//E*O*F malloc.3//'
@.TH MALLOC 3